package net.connection;

public class ConnectionManagerFactory {
	
	private ConnectionManager manager;
	private static ConnectionManagerFactory instance;
	
	private ConnectionManagerFactory(ConnectionManager manager){
		this.manager = manager;
	}
	
	public static void register(ConnectionManager manager){
		if(instance != null)
			throw new RuntimeException("A manager has already been registred.");
		
		instance = new ConnectionManagerFactory(manager);
	}
	
	public static ConnectionManagerFactory getInstance(){
		if(instance == null)
			throw new RuntimeException("No manager has been registred yet.");
		return instance;
	}
	
	public static ConnectionManager getManager(){
		return getInstance().manager;
	}
}
